package lesson20;

public class Person {

	private String name;

	void setName(String name) {
		this.name = name;
	}

	boolean hasSameName(Person other)  throws PersonException{
		try {
			//int[] x = new int [3];
			//x[10] = 4;
			
			return this.name.equals(other.name); //this code is currently unreachable because the error happens on a line before this one
		} catch (NullPointerException npe) {
			for (StackTraceElement ste : npe.getStackTrace())
				System.out.println(ste.getMethodName() + ste.getLineNumber());
			System.out.println("Name of initial person is Null!");
			//return false;
			throw new PersonException("GREDA!", npe);
			
		} catch (ArrayIndexOutOfBoundsException e)
		{
			System.out.println("Wrong use of arrays!");
			return false;
		}
	}
}
